import {formatAbnormalData } from "@/tools/util";
export function submissionsColumns(buName) {
	return [{
			title: '序号',
			type: 'index',
			width: 60,
			align: 'center'
		},
		{
			title: buName == "华润集团" ? '业务单元' : '采购人名称',
			align: "center",
			key: 'buName'
		},
		{
			title: '开标总预算',
			key: 'totalFundScaleUnit',
			align: "center",
			sortable: true,
			sortMethod: (a, b, type) => {
				this.sortMethod(type, 'totalFundScaleUnit')
			},
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.totalFundScaleUnit)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.totalFundScaleUnit))
				}
				
			}
		},
		{
			title: '未上报标段预算',
			key: 'unReportFundScaleUnit',
			align: "center",
			sortable: true,
			sortMethod: (a, b, type) => {
				this.sortMethod(type, "unReportFundScaleUnit")
			},
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.unReportFundScaleUnit)
				}else{
					return h('span', this.formatAbnormalData(params.row?.unReportFundScaleUnit))
				}
				
			}
		}
	];
}

export function attachmentsColumns(buName) {
	return [{
			title: '序号',
			type: 'index',
			width: 60,
			align: 'center'
		},
		{
			title: buName == "华润集团" ? '业务单元' : '采购人名称',
			align: "center",
			key: 'buName'
		},
		{
			title: '招采文件报送率',
			key: 'bidFileRepRate',
			align: "center",
			sortable: true,
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.bidFileRepRate)
				}
				else{
					return h('span', this.formatAbnormalData(this.toFixPercent(params.row?.bidFileRepRate)))
				}
			}
		},
		{
			title: '分项报价表报送率',
			key: 'quotationFileRepRate',
			align: "center",
			sortable: true,
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.quotationFileRepRate)
				}else{
					return h('span', this.formatAbnormalData(this.toFixPercent(params.row?.quotationFileRepRate)))
				}
			}
		}
	];
}

export function paymentColumns(buName) {
	return [{
			title: '序号',
			type: 'index',
			width: 60,
			align: 'center'
		},
		{
			title: buName == "华润集团" ? '业务单元' : '采购人名称',
			align: "center",
			key: 'buName'
		},
		{
			title: '合同履约滚动报送率',
			key: 'perfRollRepRate',
			align: "center",
			sortable: true,
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.perfRollRepRate)
				}
				else{
					return h('span', this.formatAbnormalData(this.toFixPercent(params.row?.perfRollRepRate)))
				}
				
			},
		},
		{
			title: '合同支付滚动报送率',
			key: 'payRollRepRate',
			align: "center",
			sortable: true,
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.payRollRepRate)
				}
				else{
					return h('span', this.formatAbnormalData(this.toFixPercent(params.row?.payRollRepRate)))
				}
			},
		}
	];
}

export function subFormColumns(buName) {
	return [{
			title: '序号',
			type: 'index',
			width: 60,
			align: 'center'
		},
		{
			title: buName == "华润集团" ? '业务单元' : '采购人名称',
			align: "center",
			key: 'buName',
		},
		{
			title: '上报标段数',
			key: 'biddingCount',
			align: "center",
			render: (h, params) => {
				if(params?.row.isEmpty){
					return h('span', params.row?.biddingCount)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.biddingCount))
				}
			}
		},
		{
			title: '报送表单结构完整率',
			key: 'tbFullRate',
			align: "center",
			slot: "fullRate",
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.tbFullRate)
				}
				else{
					return h('span', this.formatAbnormalData(this.toFixPercent(params.row?.tbFullRate)))
				}
			},
			renderHeader: (h, params) => {
				return h('div', {
					style: {
						display: 'flex',
						alignItems: "center"
					}
				}, [
					h('span', params.column.title),
					h("RowTools", {
						props: {
							data: [{
								type: 'icon',
								icon: 'md-help-circle',
								text: '完整报送表1-表8的标段占比',
							}, ]
						},
						style: {
							marginLeft: "4px",
							color: "#000"
						},
						class: "row-tips"
					})
				])
			}
		},
		{
			title: '招采阶段完整报送',
			key: 'purchaserCount',
			align: "center",
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.purchaserCount)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.purchaserCount))
				}
			},
			renderHeader: (h, params) => {
				return h('div', {
					style: {
						display: 'flex',
						alignItems: "center"
					}
				}, [
					h('span', params.column.title),
					h("RowTools", {
						props: {
							data: [{
								type: 'icon',
								icon: 'md-help-circle',
								text: '距开标日期大于90天，仅表1-3报送',
							}, ]
						},
						style: {
							marginLeft: "4px",
							color: "#ec808d"
						},
						class: "row-tips-warn"
					})
				])
			}
		},
		{
			title: '合同阶段完整报送',
			key: 'contractFullCount',
			align: "center",
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.contractFullCount)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.contractFullCount))
				}
			},
			renderHeader: (h, params) => {
				return h('div', {
					style: {
						display: 'flex',
						alignItems: "center"
					}
				}, [
					h('span', params.column.title),
					h("RowTools", {
						props: {
							data: [{
								type: 'icon',
								icon: 'md-help-circle',
								text: '报送表1，表4-8（缺少表2，表3）',
							}, ]
						},
						style: {
							marginLeft: "4px",
							color: "#000"
						},
						class: "row-tips-warn"
					})
				])
			}
		},
		{
			title: '合同阶段部分缺失',
			key: 'contractPartCount',
			align: "center",
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.contractPartCount)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.contractPartCount))
				}
			},
			renderHeader: (h, params) => {
				return h('div', {
					style: {
						display: 'flex',
						alignItems: "center"
					}
				}, [
					h('span', params.column.title),
					h("RowTools", {
						props: {
							data: [{
								type: 'icon',
								icon: 'md-help-circle',
								text: '报送表1-3，表4-8随机缺失',
							}, ]
						},
						style: {
							marginLeft: "4px",
							color: "#000"
						},
						class: "row-tips-warn"
					})
				])
			}
		},
		{
			title: '表单无序缺失',
			key: 'unorderedCount',
			align: "center",
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.unorderedCount)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.unorderedCount))
				}
			},
			renderHeader: (h, params) => {
				return h('div', {
					style: {
						display: 'flex',
						alignItems: "center"
					}
				}, [
					h('span', params.column.title),
					h("RowTools", {
						props: {
							data: [{
								type: 'icon',
								icon: 'md-help-circle',
								text: '报送表1，其他表单无序缺失',
							}, ]
						},
						style: {
							marginLeft: "4px",
							color: "#000"
						},
						class: "row-tips-warn"
					})
				])
			}
		},
		{
			title: '表单关联失效',
			key: 'disabledCount',
			align: "center",
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.disabledCount)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.disabledCount))
				}
			},
			renderHeader: (h, params) => {
				return h('div', {
					style: {
						display: 'flex',
						alignItems: "center"
					}
				}, [
					h('span', params.column.title),
					h("RowTools", {
						props: {
							data: [{
								type: 'icon',
								icon: 'md-help-circle',
								text: '缺失表1',
							}, ]
						},
						style: {
							marginLeft: "4px",
							color: "#000"
						},
						class: "row-tips-warn"
					})
				])
			}
		}
	];
}

export function frameworkColumns(buName) {
	return [{
			title: '序号',
			type: 'index',
			width: 60,
			align: 'center'
		},
		{
			title: buName == "华润集团" ? '业务单元' : '采购人名称',
			align: "center",
			key: 'buName'
		},
		{
			title: '应包含框架协议的上报合同总数',
			key: 'contractCount',
			align: "center",
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.contractCount)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.contractCount))
				}
			},
			minWidth: 200,
			renderHeader: (h, params) => {
				return h('div', {
						style: {
							display: 'flex',
							alignItems: "center"
						}
					},
					[
						h('span', params.column.title),
						h('Tooltip', {
								props: {
									placement: 'top',
									content: "",
									transfer: true,
									maxWidth: "220"
								},
							},
							[
								h("Icon", {
									props: {
										type: 'md-help-circle',
									},
									style: {
										cursor: "pointer",
										marginLeft: "4px",
										color: "#000"
									},
								}),
								h('div', {
										slot: 'content'
									},
									[
										h("p", {
											style: {
												fontSize: "16px",
												fontWeight: "bold",
												marginBottom: "10px"
											}
										}, "应上报框架协议"),
										h("p", "情况1：表1[单一来源采购属性]为“框架协议执行"),
										h("p", "情况2：标段名称及合同名称中包含“框架”或“订单”字样"),
										h("p", "情况3：除以上情况外，表4填写框架协议编号"),
									]

								)
							]
						)
					]
				)
			}
		},
		{
			title: '框架协议完整报送率',
			key: 'fullRate',
			align: "center",
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.fullRate)
				}
				else{
					return h('span', this.formatAbnormalData(this.toFixPercent(params.row?.fullRate)))
				}
			},
			renderHeader: (h, params) => {
				return h('div', {
						style: {
							display: 'flex',
							alignItems: "center"
						}
					},
					[
						h('span', params.column.title),
						h('Tooltip', {
								props: {
									placement: 'top',
									content: "完整报送框架协议及子协议的合同数占比",
									transfer: true,
									maxWidth: "150"
								},
							},
							[
								h("Icon", {
									props: {
										type: 'md-help-circle',
									},
									style: {
										cursor: "pointer",
										marginLeft: "4px",
										color: "#000"
									},
								})
							]
						)
					]
				)
			}
		},
		{
			title: '仅报送子协议（未填写框架协议编码）',
			key: 'subProtocolNotFillCount',
			align: "center",
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.subProtocolNotFillCount)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.subProtocolNotFillCount))
				}
			},
			renderHeader: (h, params) => {
				return h('div', {
						style: {
							display: 'flex'
						}
					},
					[
						h('div', {
								style: {
									display: 'flex',
									flexDirection: "column",
									alignItems: "center",
								},
							},

							[h('div',
									[
										h('span', "仅报送子协议"),
										h('Tooltip', {
												props: {
													placement: 'top',
													content: "未填写框架协议编码，未报送送框架协议，仅上报子协议的合同数",
													transfer: true,
													maxWidth: "160"
												},
											},
											[
												h("Icon", {
													props: {
														type: 'md-help-circle',
													},
													style: {
														cursor: "pointer",
														color: "#ec808d",
														marginLeft: "4px",
														marginBottom: "4px"
													},
												})
											])
									]
								),
								h('div', "（未填写框架协议编码）")
							]
						),
					]
				)
			}
		},
		{
			title: '仅报送子协议（有填写框架协议编码）',
			key: 'subProtocolFillCount',
			align: "center",
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.subProtocolFillCount)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.subProtocolFillCount))
				}
			},
			renderHeader: (h, params) => {
				return h('div', {
						style: {
							display: 'flex'
						}
					},
					[
						h('div', {
								style: {
									display: 'flex',
									flexDirection: "column",
									alignItems: "center",
								},
							},

							[h('div',
									[
										h('span', "仅报送子协议"),
										h('Tooltip', {
												props: {
													placement: 'top',
													content: "填写框架协议编码，未报送框架协议，仅上报子协议的合同数",
													transfer: true,
													maxWidth: "160"
												},
											},
											[
												h("Icon", {
													props: {
														type: 'md-help-circle',
													},
													style: {
														cursor: "pointer",
														color: "#ec808d",
														marginLeft: "4px",
														marginBottom: "4px"
													},
												})
											])
									]
								),
								h('div', "（有填写框架协议编码）")
							])
					]
				)
			}
		},
		{
			title: '仅报送框架协议（未上报子协议）',
			key: 'frameworkArgCount',
			align: "center",
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.frameworkArgCount)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.frameworkArgCount))
				}
			},
			width: 200,
			renderHeader: (h, params) => {
				return h('div', {
						style: {
							display: 'flex'
						}
					},
					[
						h('div', {
								style: {
									display: 'flex',
									flexDirection: "column",
									alignItems: "center",
								},
							},

							[h('div',
									[
										h('span', "仅报送框架协议"),
										h('Tooltip', {
												props: {
													placement: 'top',
													content: "填写框架协议编码，仅报送框架协议，未上报子协议的合同数",
													transfer: true,
													maxWidth: "160"
												},
											},
											[
												h("Icon", {
													props: {
														type: 'md-help-circle',
													},
													style: {
														cursor: "pointer",
														color: "#ec808d",
														marginLeft: "4px",
														marginBottom: "4px"
													},
												})
											])
									]
								),
								h('div', "（未上报子协议）")
							])
					]
				)
			}
		}
	];
}

export function bidDocColumns(buName) {
	return [{
			title: '序号',
			type: 'index',
			width: 60,
			align: 'center'
		},
		{
			title: buName == "华润集团" ? '业务单元' : '采购人名称',
			align: "center",
			key: 'buName'
		},
		{
			title: '未报送完整招采文件',
			key: 'unreportAll',
			align: "center",
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.unreportAll)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.unreportAll))
				}
			}
		},
		{
			title: '缺失采购文件附件',
			key: 'missFilePart',
			align: "center",
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.missFilePart)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.missFilePart))
				}
			}
		},
		{
			title: '缺少采购文件正文',
			align: "center",
			key: 'missText',
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.missText)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.missText))
				}
			}
		},
		{
			title: '缺失招采文件',
			key: 'missFile',
			align: "center",
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.missFile)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.missFile))
				}
			},
			width: 130
		},
		{
			title: '缺失采购文件(商务部分)',
			key: 'missBusiness',
			align: "center",
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.missBusiness)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.missBusiness))
				}
			}
		},
		{
			title: '缺失工程量清单',
			align: "center",
			key: 'missBoq',
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.missBoq)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.missBoq))
				}
			},
			width: 140
		},
		{
			title: '缺失价格清单',
			key: 'missPrice',
			align: "center",
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.missPrice)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.missPrice))
				}
			},
			maxWidth: 130
		}
	];
}

export function quotationColumns(buName) {
	return [{
			title: '序号',
			type: 'index',
			width: 60,
			align: 'center'
		},
		{
			title: buName == "华润集团" ? '业务单元' : '采购人名称',
			align: "center",
			key: 'buName'
		},
		{
			title: '未提供分项报价表',
			key: 'missQuotation',
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.missQuotation)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.missQuotation))
				}
			},
			align: "center",
		},
		{
			title: '附件表格未展示在一页',
			key: 'fileNoOnePage',
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.fileNoOnePage)
				}
				else{
					return h('span', this.formatAbnormalData(params.row?.fileNoOnePage))
				}
			},
			align: "center",
		},
		{
			title: '空白文件',
			align: "center",
			key: 'blankFile'
		}
	];
}

export function qualityColumns() {
	return [{
			title: '问题标签',
			key: 'problemLabel',
			align: "center",
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.problemLabel)
				}
				else{
					return h('span', formatAbnormalData(params.row?.problemLabel))
				}
			}
		},
		{
			title: '问题描述',
			key: 'problemInfo',
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.problemInfo)
				}
				else{
					return h('span', formatAbnormalData(params.row?.problemInfo))
				}
			},
			align: "center"
		},
		{
			title: '所属表',
			align: 'center',
			key: 'tbName',
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.tbName)
				}
				else{
					return h('span', formatAbnormalData(params.row?.tbName))
				}
			},
			width: '100'
		},
		{
			title: '报错数量',
			align: "center",
			key: 'problemNum',
			render: (h, params) => {
				if(params?.row?.isEmpty){
					return h('span', params.row?.problemNum)
				}
				else{
					return h('span', formatAbnormalData(params.row?.problemNum))
				}
			},
			width: '100',

		}
	];
}